# reticulate::use_condaenv("wompwomp_env", required = TRUE) # !!! erase
# devtools::load_all() # !!! erase

library(wompwomp)  #!!! uncomment
library(dplyr)
library(ggplot2)
library(ggalluvial)
library(ggforce)
library(igraph)
library(tibble)
library(tidyr)
library(reticulate)

set.seed(42)

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

Set up our python environment

wompwomp::setup_python_env()

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

use_temp_dir <- FALSE

use_temp_dir <- (use_temp_dir || !interactive()) # ensure temp_dire when non-interactive always
output_dir <- ifelse(!use_temp_dir, here::here("vignettes", "output"), file.path(tempdir(), "vignette_output"))
dir.create(output_dir, recursive = TRUE, showWarnings = FALSE)

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

GOT

url <- "https://raw.githubusercontent.com/MattLunkes/GoT_Affiliations/master/got_char.csv"
got_file <- file.path(output_dir, "got_char.csv")
graphing_columns <- c("Origin", "Starting.Affiliation", "End.of.S1", "End.of.S2", "End.of.S3", "End.of.S4", "End.of.S5", "End.of.S6", "End.of.S7")

if (!file.exists(got_file)) {
    download.file(url, got_file, method = "curl")
}

df <- read.csv(got_file)

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "none", default_sorting = "alphabetical", coloring_algorithm = "left", color_bands = FALSE, verbose = TRUE, output_plot_path = file.path(output_dir, "GoT_unsorted_alphabetical.pdf"), min_text = 0.01, save_height = 24, save_width = 24, text_size = 35, axis_text_size = 25, axis_text_vjust = -5, text_width = 0.5)
## Loading in data
## Preprocessing data before sorting
## Alluvial statistics: n = number of elements; m = number of graphing columns; a = number of alluvia/edges; k_i = number of blocks in layer i (where i goes from 1:m); K_sum = number of blocks across all layers; K_prod = product of blocks across all layers
## n = 488
## m = 9
## a = 183
## k_1 = 13
## k_2 = 12
## k_3 = 17
## k_4 = 16
## k_5 = 14
## k_6 = 15
## k_7 = 16
## k_8 = 11
## k_9 = 8
## K_sum = 122
## K_prod = 12546293760
## Sorting data with sorting_algorithm=none
## Determining crossing edges objective (to disable, use verbose==FALSE)
## crossing edges objective = 123924
## Complete with sorting
## Plotting data
## Saving plot to=/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T//Rtmp1kOc9s/vignette_output/GoT_unsorted_alphabetical.pdf
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "none", default_sorting = "reverse_alphabetical", coloring_algorithm = "left", color_bands = FALSE, verbose = TRUE, output_plot_path = file.path(output_dir, "GoT_unsorted_reverse_alphabetical.pdf"), min_text = 0.01, save_height = 24, save_width = 24, text_size = 35, axis_text_size = 25, axis_text_vjust = -5, text_width = 0.5)
## Loading in data
## Preprocessing data before sorting
## Alluvial statistics: n = number of elements; m = number of graphing columns; a = number of alluvia/edges; k_i = number of blocks in layer i (where i goes from 1:m); K_sum = number of blocks across all layers; K_prod = product of blocks across all layers
## n = 488
## m = 9
## a = 183
## k_1 = 13
## k_2 = 12
## k_3 = 17
## k_4 = 16
## k_5 = 14
## k_6 = 15
## k_7 = 16
## k_8 = 11
## k_9 = 8
## K_sum = 122
## K_prod = 12546293760
## Sorting data with sorting_algorithm=none
## Determining crossing edges objective (to disable, use verbose==FALSE)
## crossing edges objective = 123924
## Complete with sorting
## Plotting data
## Saving plot to=/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T//Rtmp1kOc9s/vignette_output/GoT_unsorted_reverse_alphabetical.pdf
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "none", default_sorting = "increasing", coloring_algorithm = "left", color_bands = FALSE, verbose = TRUE, output_plot_path = file.path(output_dir, "GoT_unsorted_increasing.pdf"), min_text = 0.01, save_height = 24, save_width = 24, text_size = 35, axis_text_size = 25, axis_text_vjust = -5, text_width = 0.5)
## Loading in data
## Preprocessing data before sorting
## Alluvial statistics: n = number of elements; m = number of graphing columns; a = number of alluvia/edges; k_i = number of blocks in layer i (where i goes from 1:m); K_sum = number of blocks across all layers; K_prod = product of blocks across all layers
## n = 488
## m = 9
## a = 183
## k_1 = 13
## k_2 = 12
## k_3 = 17
## k_4 = 16
## k_5 = 14
## k_6 = 15
## k_7 = 16
## k_8 = 11
## k_9 = 8
## K_sum = 122
## K_prod = 12546293760
## Sorting data with sorting_algorithm=none
## Determining crossing edges objective (to disable, use verbose==FALSE)
## crossing edges objective = 193466
## Complete with sorting
## Plotting data
## Saving plot to=/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T//Rtmp1kOc9s/vignette_output/GoT_unsorted_increasing.pdf
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "none", default_sorting = "decreasing", coloring_algorithm = "left", color_bands = FALSE, verbose = TRUE, output_plot_path = file.path(output_dir, "GoT_unsorted_decreasing.pdf"), min_text = 0.01, save_height = 24, save_width = 24, text_size = 35, axis_text_size = 25, axis_text_vjust = -5, text_width = 0.5)
## Loading in data
## Preprocessing data before sorting
## Alluvial statistics: n = number of elements; m = number of graphing columns; a = number of alluvia/edges; k_i = number of blocks in layer i (where i goes from 1:m); K_sum = number of blocks across all layers; K_prod = product of blocks across all layers
## n = 488
## m = 9
## a = 183
## k_1 = 13
## k_2 = 12
## k_3 = 17
## k_4 = 16
## k_5 = 14
## k_6 = 15
## k_7 = 16
## k_8 = 11
## k_9 = 8
## K_sum = 122
## K_prod = 12546293760
## Sorting data with sorting_algorithm=none
## Determining crossing edges objective (to disable, use verbose==FALSE)
## crossing edges objective = 192189
## Complete with sorting
## Plotting data
## Saving plot to=/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T//Rtmp1kOc9s/vignette_output/GoT_unsorted_decreasing.pdf
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

set.seed(42)
p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "random", coloring_algorithm = "left", color_bands = FALSE, verbose = TRUE, output_plot_path = file.path(output_dir, "GoT_random.pdf"), min_text = 0.01, save_height = 24, save_width = 24, text_size = 35, axis_text_size = 25, axis_text_vjust = -5, text_width = 0.5)
## Loading in data
## Preprocessing data before sorting
## Alluvial statistics: n = number of elements; m = number of graphing columns; a = number of alluvia/edges; k_i = number of blocks in layer i (where i goes from 1:m); K_sum = number of blocks across all layers; K_prod = product of blocks across all layers
## n = 488
## m = 9
## a = 183
## k_1 = 13
## k_2 = 12
## k_3 = 17
## k_4 = 16
## k_5 = 14
## k_6 = 15
## k_7 = 16
## k_8 = 11
## k_9 = 8
## K_sum = 122
## K_prod = 12546293760
## Sorting data with sorting_algorithm=random
## Determining crossing edges objective (to disable, use verbose==FALSE)
## crossing edges objective = 343087
## Complete with sorting
## Plotting data
## Saving plot to=/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T//Rtmp1kOc9s/vignette_output/GoT_random.pdf
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

# df['Lannister_origin'] <- df["Origin"] == 'House Lannister'
df <- df %>%
    mutate(Lannister_origin = case_when(
        Origin == "House Lannister" ~ 1,
        Origin == "Westeros" ~ 2,
        TRUE ~ 0
    ))
set.seed(42)
p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "random", optimize_column_order = FALSE, color_boxes = FALSE, color_bands = TRUE, min_text = 0.01, verbose = FALSE, color_band_list = c("0" = "grey", "1" = "#D55E00", "2" = "#56B4E9"), color_band_column = "Lannister_origin", output_plot_path = file.path(output_dir, "GoT_random_lannister_origin.pdf"), save_height = 24, save_width = 24, text_size = 35, axis_text_size = 25, axis_text_vjust = -5, text_width = 0.5)
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

# df['Lannister_ending'] <- df["End.of.S7"] == 'Queen Cersei Lannister'
df <- df %>%
    mutate(Lannister_ending = case_when(
        End.of.S7 == "Queen Cersei Lannister" ~ 1,
        End.of.S7 == "Other, Westeros" ~ 2,
        TRUE ~ 0
    ))
set.seed(42)
p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "random", optimize_column_order = FALSE, color_boxes = FALSE, color_bands = TRUE, min_text = 0.01, verbose = FALSE, color_band_list = c("0" = "grey", "1" = "#D55E00", "2" = "#56B4E9"), color_band_column = "Lannister_ending", output_plot_path = file.path(output_dir, "GoT_random_lannister_ending.pdf"), save_height = 24, save_width = 24, text_size = 35, axis_text_size = 25, axis_text_vjust = -5, text_width = 0.5)
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "neighbornet", optimize_column_order = FALSE, color_bands = FALSE, coloring_algorithm = "left", min_text = 0.01, verbose = TRUE, output_plot_path = file.path(output_dir, "GoT_NN.pdf"), save_height = 24, save_width = 24, text_size = 35, axis_text_size = 25, axis_text_vjust = -5, text_width = 0.5)
## Loading in data
## Preprocessing data before sorting
## Alluvial statistics: n = number of elements; m = number of graphing columns; a = number of alluvia/edges; k_i = number of blocks in layer i (where i goes from 1:m); K_sum = number of blocks across all layers; K_prod = product of blocks across all layers
## n = 488
## m = 9
## a = 183
## k_1 = 13
## k_2 = 12
## k_3 = 17
## k_4 = 16
## k_5 = 14
## k_6 = 15
## k_7 = 16
## k_8 = 11
## k_9 = 8
## K_sum = 122
## K_prod = 12546293760
## Sorting data with sorting_algorithm=neighbornet
## Running neighbornet
## Running 'neighbornet' for stratum order
## Cycle: End.of.S1~~Balon Greyjoy, King of the Iron Islands, Origin~~House Greyjoy, End.of.S2~~Balon Greyjoy, King of the Iron Islands, End.of.S3~~Balon Greyjoy, King of the Iron Islands, End.of.S4~~Balon Greyjoy, King of the Iron Islands, End.of.S5~~Balon Greyjoy, King of the Iron Islands, End.of.S6~~Euron Greyjoy, King of the Iron Islands, Starting.Affiliation~~Deceased, End.of.S2~~Qarth, End.of.S1~~Qarth, Starting.Affiliation~~Qarth, End.of.S5~~Sons of the Harpy, End.of.S4~~Sons of the Harpy, Starting.Affiliation~~Essos Slavers, End.of.S2~~Essos Slavers, End.of.S1~~Essos Slavers, End.of.S3~~Essos Slavers, Starting.Affiliation~~Khal Drogo, End.of.S1~~Daenerys Targaryen, End.of.S2~~Daenerys Targaryen, End.of.S3~~Daenerys Targaryen, End.of.S4~~Daenerys Targaryen, End.of.S5~~Daenerys Targaryen, End.of.S7~~Daenerys Targaryen, End.of.S6~~Daenerys Targaryen, Origin~~Essos, End.of.S4~~Other, Essos, End.of.S3~~Other, Essos, End.of.S6~~Other, Essos, End.of.S7~~Other, Essos, End.of.S5~~Other, Essos, End.of.S1~~Other, Essos, End.of.S2~~Other, Essos, Starting.Affiliation~~Other, Essos, End.of.S4~~Dothraki, End.of.S1~~Dothraki, End.of.S2~~Dothraki, End.of.S3~~Dothraki, End.of.S5~~Dothraki, Starting.Affiliation~~Other Dothraki, End.of.S5~~Sand Snakes, End.of.S4~~Sand Snakes, Origin~~House Martell, Starting.Affiliation~~Viserys Targaryen, Origin~~House Targaryen, End.of.S1~~Night's Watch, Starting.Affiliation~~Night's Watch, End.of.S2~~Night's Watch, End.of.S3~~Night's Watch, End.of.S5~~Night's Watch, End.of.S6~~Night's Watch, End.of.S7~~Night's Watch, End.of.S4~~Night's Watch, End.of.S6~~Deceased, End.of.S1~~Deceased, End.of.S2~~Deceased, End.of.S3~~Deceased, End.of.S4~~Deceased, End.of.S5~~Deceased, End.of.S7~~Deceased, Origin~~House Stark, End.of.S5~~Roose Bolton, Lord Paramount of the North, End.of.S2~~Robb Stark, King in the North, End.of.S1~~Robb Stark, King in the North, Starting.Affiliation~~King Robert Baratheon, Origin~~House Tully, End.of.S3~~Other, Westeros, End.of.S5~~Other, Westeros, End.of.S7~~Other, Westeros, End.of.S6~~Other, Westeros, End.of.S4~~Other, Westeros, End.of.S2~~Other, Westeros, End.of.S1~~Other, Westeros, Starting.Affiliation~~Other, Westeros, Origin~~Westeros, End.of.S5~~High Sparrow, End.of.S3~~King Joffrey Baratheon, End.of.S4~~King Tommen Baratheon, End.of.S5~~King Tommen Baratheon, End.of.S6~~Queen Cersei Lannister, End.of.S7~~Queen Cersei Lannister, End.of.S2~~King Joffrey Baratheon, End.of.S1~~King Joffrey Baratheon, Origin~~House Lannister, Origin~~House Tyrell, End.of.S1~~King Renly Baratheon, Origin~~House Baratheon, End.of.S1~~King Stannis Baratheon, End.of.S3~~King Stannis Baratheon, End.of.S4~~King Stannis Baratheon, End.of.S2~~King Stannis Baratheon, End.of.S2~~Brotherhood Without Banners, End.of.S1~~Brotherhood Without Banners, End.of.S3~~Brotherhood Without Banners, End.of.S4~~Brotherhood Without Banners, End.of.S5~~Brotherhood Without Banners, End.of.S6~~Brotherhood Without Banners, Origin~~Wildlings, Starting.Affiliation~~Wildlings, End.of.S2~~Wildlings, End.of.S1~~Wildlings, End.of.S3~~Wildlings, End.of.S4~~Wildlings, End.of.S5~~Wildlings, End.of.S6~~Jon Snow, King in the North, End.of.S7~~Jon Snow, King in the North, Origin~~House Arryn, End.of.S4~~Petyr Baelish, Lord Protector of the Vale, End.of.S5~~Petyr Baelish, Lord Protector of the Vale, End.of.S3~~House Arryn (Neutral), End.of.S1~~House Arryn (Neutral), End.of.S2~~House Arryn (Neutral), End.of.S6~~Petyr Baelish, Lord Protector of the Vale, End.of.S7~~White Walkers, End.of.S5~~White Walkers, End.of.S6~~White Walkers, End.of.S4~~White Walkers, End.of.S3~~White Walkers, End.of.S1~~White Walkers, End.of.S2~~White Walkers, Starting.Affiliation~~White Walkers, Origin~~White Walkers
## Determining optimal cycle start
## Starting iteration 1 / 122
## neighbornet_objective for iteration 1 = 63295
## Starting iteration 2 / 122
## neighbornet_objective for iteration 2 = 68534
## Starting iteration 3 / 122
## neighbornet_objective for iteration 3 = 66798
## Starting iteration 4 / 122
## neighbornet_objective for iteration 4 = 67281
## Starting iteration 5 / 122
## neighbornet_objective for iteration 5 = 66553
## Starting iteration 6 / 122
## neighbornet_objective for iteration 6 = 66551
## Starting iteration 7 / 122
## neighbornet_objective for iteration 7 = 66090
## Starting iteration 8 / 122
## neighbornet_objective for iteration 8 = 62905
## Starting iteration 9 / 122
## neighbornet_objective for iteration 9 = 63194
## Starting iteration 10 / 122
## neighbornet_objective for iteration 10 = 64032
## Starting iteration 11 / 122
## neighbornet_objective for iteration 11 = 67407
## Starting iteration 12 / 122
## neighbornet_objective for iteration 12 = 66705
## Starting iteration 13 / 122
## neighbornet_objective for iteration 13 = 79919
## Starting iteration 14 / 122
## neighbornet_objective for iteration 14 = 79697
## Starting iteration 15 / 122
## neighbornet_objective for iteration 15 = 112217
## Starting iteration 16 / 122
## neighbornet_objective for iteration 16 = 146183
## Starting iteration 17 / 122
## neighbornet_objective for iteration 17 = 110984
## Starting iteration 18 / 122
## neighbornet_objective for iteration 18 = 101749
## Starting iteration 19 / 122
## neighbornet_objective for iteration 19 = 110091
## Starting iteration 20 / 122
## neighbornet_objective for iteration 20 = 115804
## Starting iteration 21 / 122
## neighbornet_objective for iteration 21 = 115704
## Starting iteration 22 / 122
## neighbornet_objective for iteration 22 = 113139
## Starting iteration 23 / 122
## neighbornet_objective for iteration 23 = 110998
## Starting iteration 24 / 122
## neighbornet_objective for iteration 24 = 110835
## Starting iteration 25 / 122
## neighbornet_objective for iteration 25 = 134620
## Starting iteration 26 / 122
## neighbornet_objective for iteration 26 = 99946
## Starting iteration 27 / 122
## neighbornet_objective for iteration 27 = 102125
## Starting iteration 28 / 122
## neighbornet_objective for iteration 28 = 128064
## Starting iteration 29 / 122
## neighbornet_objective for iteration 29 = 126205
## Starting iteration 30 / 122
## neighbornet_objective for iteration 30 = 151220
## Starting iteration 31 / 122
## neighbornet_objective for iteration 31 = 138340
## Starting iteration 32 / 122
## neighbornet_objective for iteration 32 = 110898
## Starting iteration 33 / 122
## neighbornet_objective for iteration 33 = 140859
## Starting iteration 34 / 122
## neighbornet_objective for iteration 34 = 112500
## Starting iteration 35 / 122
## neighbornet_objective for iteration 35 = 80640
## Starting iteration 36 / 122
## neighbornet_objective for iteration 36 = 99360
## Starting iteration 37 / 122
## neighbornet_objective for iteration 37 = 116358
## Starting iteration 38 / 122
## neighbornet_objective for iteration 38 = 116358
## Starting iteration 39 / 122
## neighbornet_objective for iteration 39 = 97638
## Starting iteration 40 / 122
## neighbornet_objective for iteration 40 = 84472
## Starting iteration 41 / 122
## neighbornet_objective for iteration 41 = 69510
## Starting iteration 42 / 122
## neighbornet_objective for iteration 42 = 70146
## Starting iteration 43 / 122
## neighbornet_objective for iteration 43 = 68182
## Starting iteration 44 / 122
## neighbornet_objective for iteration 44 = 69569
## Starting iteration 45 / 122
## neighbornet_objective for iteration 45 = 69871
## Starting iteration 46 / 122
## neighbornet_objective for iteration 46 = 70198
## Starting iteration 47 / 122
## neighbornet_objective for iteration 47 = 103703
## Starting iteration 48 / 122
## neighbornet_objective for iteration 48 = 93752
## Starting iteration 49 / 122
## neighbornet_objective for iteration 49 = 93940
## Starting iteration 50 / 122
## neighbornet_objective for iteration 50 = 93599
## Starting iteration 51 / 122
## neighbornet_objective for iteration 51 = 114908
## Starting iteration 52 / 122
## neighbornet_objective for iteration 52 = 114986
## Starting iteration 53 / 122
## neighbornet_objective for iteration 53 = 105626
## Starting iteration 54 / 122
## neighbornet_objective for iteration 54 = 83368
## Starting iteration 55 / 122
## neighbornet_objective for iteration 55 = 182857
## Starting iteration 56 / 122
## neighbornet_objective for iteration 56 = 195335
## Starting iteration 57 / 122
## neighbornet_objective for iteration 57 = 207356
## Starting iteration 58 / 122
## neighbornet_objective for iteration 58 = 217970
## Starting iteration 59 / 122
## neighbornet_objective for iteration 59 = 228331
## Starting iteration 60 / 122
## neighbornet_objective for iteration 60 = 147868
## Starting iteration 61 / 122
## neighbornet_objective for iteration 61 = 93244
## Starting iteration 62 / 122
## neighbornet_objective for iteration 62 = 113646
## Starting iteration 63 / 122
## neighbornet_objective for iteration 63 = 117666
## Starting iteration 64 / 122
## neighbornet_objective for iteration 64 = 156784
## Starting iteration 65 / 122
## neighbornet_objective for iteration 65 = 142976
## Starting iteration 66 / 122
## neighbornet_objective for iteration 66 = 130734
## Starting iteration 67 / 122
## neighbornet_objective for iteration 67 = 121388
## Starting iteration 68 / 122
## neighbornet_objective for iteration 68 = 165681
## Starting iteration 69 / 122
## neighbornet_objective for iteration 69 = 217180
## Starting iteration 70 / 122
## neighbornet_objective for iteration 70 = 238589
## Starting iteration 71 / 122
## neighbornet_objective for iteration 71 = 197797
## Starting iteration 72 / 122
## neighbornet_objective for iteration 72 = 141234
## Starting iteration 73 / 122
## neighbornet_objective for iteration 73 = 140881
## Starting iteration 74 / 122
## neighbornet_objective for iteration 74 = 139249
## Starting iteration 75 / 122
## neighbornet_objective for iteration 75 = 142303
## Starting iteration 76 / 122
## neighbornet_objective for iteration 76 = 118698
## Starting iteration 77 / 122
## neighbornet_objective for iteration 77 = 118629
## Starting iteration 78 / 122
## neighbornet_objective for iteration 78 = 169162
## Starting iteration 79 / 122
## neighbornet_objective for iteration 79 = 151874
## Starting iteration 80 / 122
## neighbornet_objective for iteration 80 = 144722
## Starting iteration 81 / 122
## neighbornet_objective for iteration 81 = 140100
## Starting iteration 82 / 122
## neighbornet_objective for iteration 82 = 126308
## Starting iteration 83 / 122
## neighbornet_objective for iteration 83 = 127234
## Starting iteration 84 / 122
## neighbornet_objective for iteration 84 = 94873
## Starting iteration 85 / 122
## neighbornet_objective for iteration 85 = 86574
## Starting iteration 86 / 122
## neighbornet_objective for iteration 86 = 86605
## Starting iteration 87 / 122
## neighbornet_objective for iteration 87 = 80011
## Starting iteration 88 / 122
## neighbornet_objective for iteration 88 = 73857
## Starting iteration 89 / 122
## neighbornet_objective for iteration 89 = 74761
## Starting iteration 90 / 122
## neighbornet_objective for iteration 90 = 80906
## Starting iteration 91 / 122
## neighbornet_objective for iteration 91 = 78858
## Starting iteration 92 / 122
## neighbornet_objective for iteration 92 = 72448
## Starting iteration 93 / 122
## neighbornet_objective for iteration 93 = 81070
## Starting iteration 94 / 122
## neighbornet_objective for iteration 94 = 73675
## Starting iteration 95 / 122
## neighbornet_objective for iteration 95 = 73675
## Starting iteration 96 / 122
## neighbornet_objective for iteration 96 = 73661
## Starting iteration 97 / 122
## neighbornet_objective for iteration 97 = 71056
## Starting iteration 98 / 122
## neighbornet_objective for iteration 98 = 71003
## Starting iteration 99 / 122
## neighbornet_objective for iteration 99 = 89315
## Starting iteration 100 / 122
## neighbornet_objective for iteration 100 = 88889
## Starting iteration 101 / 122
## neighbornet_objective for iteration 101 = 115981
## Starting iteration 102 / 122
## neighbornet_objective for iteration 102 = 84167
## Starting iteration 103 / 122
## neighbornet_objective for iteration 103 = 83081
## Starting iteration 104 / 122
## neighbornet_objective for iteration 104 = 81046
## Starting iteration 105 / 122
## neighbornet_objective for iteration 105 = 78241
## Starting iteration 106 / 122
## neighbornet_objective for iteration 106 = 86713
## Starting iteration 107 / 122
## neighbornet_objective for iteration 107 = 73531
## Starting iteration 108 / 122
## neighbornet_objective for iteration 108 = 75541
## Starting iteration 109 / 122
## neighbornet_objective for iteration 109 = 85664
## Starting iteration 110 / 122
## neighbornet_objective for iteration 110 = 83844
## Starting iteration 111 / 122
## neighbornet_objective for iteration 111 = 84380
## Starting iteration 112 / 122
## neighbornet_objective for iteration 112 = 86888
## Starting iteration 113 / 122
## neighbornet_objective for iteration 113 = 75464
## Starting iteration 114 / 122
## neighbornet_objective for iteration 114 = 66759
## Starting iteration 115 / 122
## neighbornet_objective for iteration 115 = 75147
## Starting iteration 116 / 122
## neighbornet_objective for iteration 116 = 85767
## Starting iteration 117 / 122
## neighbornet_objective for iteration 117 = 69770
## Starting iteration 118 / 122
## neighbornet_objective for iteration 118 = 69836
## Starting iteration 119 / 122
## neighbornet_objective for iteration 119 = 69567
## Starting iteration 120 / 122
## neighbornet_objective for iteration 120 = 77881
## Starting iteration 121 / 122
## neighbornet_objective for iteration 121 = 68331
## Starting iteration 122 / 122
## neighbornet_objective for iteration 122 = 65695
## crossing edges objective = 62905
## Complete with sorting
## Plotting data
## Saving plot to=/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T//Rtmp1kOc9s/vignette_output/GoT_NN.pdf
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

# df['Lannister_origin'] <- df["Origin"] == 'House Lannister'
df <- df %>%
    mutate(Lannister_origin = case_when(
        Origin == "House Lannister" ~ 1,
        Origin == "Westeros" ~ 2,
        TRUE ~ 0
    ))
p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "neighbornet", optimize_column_order = FALSE, color_boxes = FALSE, color_bands = TRUE, min_text = 0.01, verbose = TRUE, color_band_list = c("0" = "grey", "1" = "#D55E00", "2" = "#56B4E9"), color_band_column = "Lannister_origin", output_plot_path = file.path(output_dir, "GoT_NN_lannister_origin.pdf"), save_height = 24, save_width = 24, text_size = 35, axis_text_size = 25, axis_text_vjust = -5, text_width = 0.5)
## Loading in data
## Preprocessing data before sorting
## Alluvial statistics: n = number of elements; m = number of graphing columns; a = number of alluvia/edges; k_i = number of blocks in layer i (where i goes from 1:m); K_sum = number of blocks across all layers; K_prod = product of blocks across all layers
## n = 488
## m = 9
## a = 183
## k_1 = 13
## k_2 = 12
## k_3 = 17
## k_4 = 16
## k_5 = 14
## k_6 = 15
## k_7 = 16
## k_8 = 11
## k_9 = 8
## K_sum = 122
## K_prod = 12546293760
## Sorting data with sorting_algorithm=neighbornet
## Running neighbornet
## Running 'neighbornet' for stratum order
## Cycle: End.of.S1~~Balon Greyjoy, King of the Iron Islands, Origin~~House Greyjoy, End.of.S2~~Balon Greyjoy, King of the Iron Islands, End.of.S3~~Balon Greyjoy, King of the Iron Islands, End.of.S4~~Balon Greyjoy, King of the Iron Islands, End.of.S5~~Balon Greyjoy, King of the Iron Islands, End.of.S6~~Euron Greyjoy, King of the Iron Islands, Starting.Affiliation~~Deceased, End.of.S2~~Qarth, End.of.S1~~Qarth, Starting.Affiliation~~Qarth, End.of.S5~~Sons of the Harpy, End.of.S4~~Sons of the Harpy, Starting.Affiliation~~Essos Slavers, End.of.S2~~Essos Slavers, End.of.S1~~Essos Slavers, End.of.S3~~Essos Slavers, Starting.Affiliation~~Khal Drogo, End.of.S1~~Daenerys Targaryen, End.of.S2~~Daenerys Targaryen, End.of.S3~~Daenerys Targaryen, End.of.S4~~Daenerys Targaryen, End.of.S5~~Daenerys Targaryen, End.of.S7~~Daenerys Targaryen, End.of.S6~~Daenerys Targaryen, Origin~~Essos, End.of.S4~~Other, Essos, End.of.S3~~Other, Essos, End.of.S6~~Other, Essos, End.of.S7~~Other, Essos, End.of.S5~~Other, Essos, End.of.S1~~Other, Essos, End.of.S2~~Other, Essos, Starting.Affiliation~~Other, Essos, End.of.S4~~Dothraki, End.of.S1~~Dothraki, End.of.S2~~Dothraki, End.of.S3~~Dothraki, End.of.S5~~Dothraki, Starting.Affiliation~~Other Dothraki, End.of.S5~~Sand Snakes, End.of.S4~~Sand Snakes, Origin~~House Martell, Starting.Affiliation~~Viserys Targaryen, Origin~~House Targaryen, End.of.S1~~Night's Watch, Starting.Affiliation~~Night's Watch, End.of.S2~~Night's Watch, End.of.S3~~Night's Watch, End.of.S5~~Night's Watch, End.of.S6~~Night's Watch, End.of.S7~~Night's Watch, End.of.S4~~Night's Watch, End.of.S6~~Deceased, End.of.S1~~Deceased, End.of.S2~~Deceased, End.of.S3~~Deceased, End.of.S4~~Deceased, End.of.S5~~Deceased, End.of.S7~~Deceased, Origin~~House Stark, End.of.S5~~Roose Bolton, Lord Paramount of the North, End.of.S2~~Robb Stark, King in the North, End.of.S1~~Robb Stark, King in the North, Starting.Affiliation~~King Robert Baratheon, Origin~~House Tully, End.of.S3~~Other, Westeros, End.of.S5~~Other, Westeros, End.of.S7~~Other, Westeros, End.of.S6~~Other, Westeros, End.of.S4~~Other, Westeros, End.of.S2~~Other, Westeros, End.of.S1~~Other, Westeros, Starting.Affiliation~~Other, Westeros, Origin~~Westeros, End.of.S5~~High Sparrow, End.of.S3~~King Joffrey Baratheon, End.of.S4~~King Tommen Baratheon, End.of.S5~~King Tommen Baratheon, End.of.S6~~Queen Cersei Lannister, End.of.S7~~Queen Cersei Lannister, End.of.S2~~King Joffrey Baratheon, End.of.S1~~King Joffrey Baratheon, Origin~~House Lannister, Origin~~House Tyrell, End.of.S1~~King Renly Baratheon, Origin~~House Baratheon, End.of.S1~~King Stannis Baratheon, End.of.S3~~King Stannis Baratheon, End.of.S4~~King Stannis Baratheon, End.of.S2~~King Stannis Baratheon, End.of.S2~~Brotherhood Without Banners, End.of.S1~~Brotherhood Without Banners, End.of.S3~~Brotherhood Without Banners, End.of.S4~~Brotherhood Without Banners, End.of.S5~~Brotherhood Without Banners, End.of.S6~~Brotherhood Without Banners, Origin~~Wildlings, Starting.Affiliation~~Wildlings, End.of.S2~~Wildlings, End.of.S1~~Wildlings, End.of.S3~~Wildlings, End.of.S4~~Wildlings, End.of.S5~~Wildlings, End.of.S6~~Jon Snow, King in the North, End.of.S7~~Jon Snow, King in the North, Origin~~House Arryn, End.of.S4~~Petyr Baelish, Lord Protector of the Vale, End.of.S5~~Petyr Baelish, Lord Protector of the Vale, End.of.S3~~House Arryn (Neutral), End.of.S1~~House Arryn (Neutral), End.of.S2~~House Arryn (Neutral), End.of.S6~~Petyr Baelish, Lord Protector of the Vale, End.of.S7~~White Walkers, End.of.S5~~White Walkers, End.of.S6~~White Walkers, End.of.S4~~White Walkers, End.of.S3~~White Walkers, End.of.S1~~White Walkers, End.of.S2~~White Walkers, Starting.Affiliation~~White Walkers, Origin~~White Walkers
## Determining optimal cycle start
## Starting iteration 1 / 122
## neighbornet_objective for iteration 1 = 63295
## Starting iteration 2 / 122
## neighbornet_objective for iteration 2 = 68534
## Starting iteration 3 / 122
## neighbornet_objective for iteration 3 = 66798
## Starting iteration 4 / 122
## neighbornet_objective for iteration 4 = 67281
## Starting iteration 5 / 122
## neighbornet_objective for iteration 5 = 66553
## Starting iteration 6 / 122
## neighbornet_objective for iteration 6 = 66551
## Starting iteration 7 / 122
## neighbornet_objective for iteration 7 = 66090
## Starting iteration 8 / 122
## neighbornet_objective for iteration 8 = 62905
## Starting iteration 9 / 122
## neighbornet_objective for iteration 9 = 63194
## Starting iteration 10 / 122
## neighbornet_objective for iteration 10 = 64032
## Starting iteration 11 / 122
## neighbornet_objective for iteration 11 = 67407
## Starting iteration 12 / 122
## neighbornet_objective for iteration 12 = 66705
## Starting iteration 13 / 122
## neighbornet_objective for iteration 13 = 79919
## Starting iteration 14 / 122
## neighbornet_objective for iteration 14 = 79697
## Starting iteration 15 / 122
## neighbornet_objective for iteration 15 = 112217
## Starting iteration 16 / 122
## neighbornet_objective for iteration 16 = 146183
## Starting iteration 17 / 122
## neighbornet_objective for iteration 17 = 110984
## Starting iteration 18 / 122
## neighbornet_objective for iteration 18 = 101749
## Starting iteration 19 / 122
## neighbornet_objective for iteration 19 = 110091
## Starting iteration 20 / 122
## neighbornet_objective for iteration 20 = 115804
## Starting iteration 21 / 122
## neighbornet_objective for iteration 21 = 115704
## Starting iteration 22 / 122
## neighbornet_objective for iteration 22 = 113139
## Starting iteration 23 / 122
## neighbornet_objective for iteration 23 = 110998
## Starting iteration 24 / 122
## neighbornet_objective for iteration 24 = 110835
## Starting iteration 25 / 122
## neighbornet_objective for iteration 25 = 134620
## Starting iteration 26 / 122
## neighbornet_objective for iteration 26 = 99946
## Starting iteration 27 / 122
## neighbornet_objective for iteration 27 = 102125
## Starting iteration 28 / 122
## neighbornet_objective for iteration 28 = 128064
## Starting iteration 29 / 122
## neighbornet_objective for iteration 29 = 126205
## Starting iteration 30 / 122
## neighbornet_objective for iteration 30 = 151220
## Starting iteration 31 / 122
## neighbornet_objective for iteration 31 = 138340
## Starting iteration 32 / 122
## neighbornet_objective for iteration 32 = 110898
## Starting iteration 33 / 122
## neighbornet_objective for iteration 33 = 140859
## Starting iteration 34 / 122
## neighbornet_objective for iteration 34 = 112500
## Starting iteration 35 / 122
## neighbornet_objective for iteration 35 = 80640
## Starting iteration 36 / 122
## neighbornet_objective for iteration 36 = 99360
## Starting iteration 37 / 122
## neighbornet_objective for iteration 37 = 116358
## Starting iteration 38 / 122
## neighbornet_objective for iteration 38 = 116358
## Starting iteration 39 / 122
## neighbornet_objective for iteration 39 = 97638
## Starting iteration 40 / 122
## neighbornet_objective for iteration 40 = 84472
## Starting iteration 41 / 122
## neighbornet_objective for iteration 41 = 69510
## Starting iteration 42 / 122
## neighbornet_objective for iteration 42 = 70146
## Starting iteration 43 / 122
## neighbornet_objective for iteration 43 = 68182
## Starting iteration 44 / 122
## neighbornet_objective for iteration 44 = 69569
## Starting iteration 45 / 122
## neighbornet_objective for iteration 45 = 69871
## Starting iteration 46 / 122
## neighbornet_objective for iteration 46 = 70198
## Starting iteration 47 / 122
## neighbornet_objective for iteration 47 = 103703
## Starting iteration 48 / 122
## neighbornet_objective for iteration 48 = 93752
## Starting iteration 49 / 122
## neighbornet_objective for iteration 49 = 93940
## Starting iteration 50 / 122
## neighbornet_objective for iteration 50 = 93599
## Starting iteration 51 / 122
## neighbornet_objective for iteration 51 = 114908
## Starting iteration 52 / 122
## neighbornet_objective for iteration 52 = 114986
## Starting iteration 53 / 122
## neighbornet_objective for iteration 53 = 105626
## Starting iteration 54 / 122
## neighbornet_objective for iteration 54 = 83368
## Starting iteration 55 / 122
## neighbornet_objective for iteration 55 = 182857
## Starting iteration 56 / 122
## neighbornet_objective for iteration 56 = 195335
## Starting iteration 57 / 122
## neighbornet_objective for iteration 57 = 207356
## Starting iteration 58 / 122
## neighbornet_objective for iteration 58 = 217970
## Starting iteration 59 / 122
## neighbornet_objective for iteration 59 = 228331
## Starting iteration 60 / 122
## neighbornet_objective for iteration 60 = 147868
## Starting iteration 61 / 122
## neighbornet_objective for iteration 61 = 93244
## Starting iteration 62 / 122
## neighbornet_objective for iteration 62 = 113646
## Starting iteration 63 / 122
## neighbornet_objective for iteration 63 = 117666
## Starting iteration 64 / 122
## neighbornet_objective for iteration 64 = 156784
## Starting iteration 65 / 122
## neighbornet_objective for iteration 65 = 142976
## Starting iteration 66 / 122
## neighbornet_objective for iteration 66 = 130734
## Starting iteration 67 / 122
## neighbornet_objective for iteration 67 = 121388
## Starting iteration 68 / 122
## neighbornet_objective for iteration 68 = 165681
## Starting iteration 69 / 122
## neighbornet_objective for iteration 69 = 217180
## Starting iteration 70 / 122
## neighbornet_objective for iteration 70 = 238589
## Starting iteration 71 / 122
## neighbornet_objective for iteration 71 = 197797
## Starting iteration 72 / 122
## neighbornet_objective for iteration 72 = 141234
## Starting iteration 73 / 122
## neighbornet_objective for iteration 73 = 140881
## Starting iteration 74 / 122
## neighbornet_objective for iteration 74 = 139249
## Starting iteration 75 / 122
## neighbornet_objective for iteration 75 = 142303
## Starting iteration 76 / 122
## neighbornet_objective for iteration 76 = 118698
## Starting iteration 77 / 122
## neighbornet_objective for iteration 77 = 118629
## Starting iteration 78 / 122
## neighbornet_objective for iteration 78 = 169162
## Starting iteration 79 / 122
## neighbornet_objective for iteration 79 = 151874
## Starting iteration 80 / 122
## neighbornet_objective for iteration 80 = 144722
## Starting iteration 81 / 122
## neighbornet_objective for iteration 81 = 140100
## Starting iteration 82 / 122
## neighbornet_objective for iteration 82 = 126308
## Starting iteration 83 / 122
## neighbornet_objective for iteration 83 = 127234
## Starting iteration 84 / 122
## neighbornet_objective for iteration 84 = 94873
## Starting iteration 85 / 122
## neighbornet_objective for iteration 85 = 86574
## Starting iteration 86 / 122
## neighbornet_objective for iteration 86 = 86605
## Starting iteration 87 / 122
## neighbornet_objective for iteration 87 = 80011
## Starting iteration 88 / 122
## neighbornet_objective for iteration 88 = 73857
## Starting iteration 89 / 122
## neighbornet_objective for iteration 89 = 74761
## Starting iteration 90 / 122
## neighbornet_objective for iteration 90 = 80906
## Starting iteration 91 / 122
## neighbornet_objective for iteration 91 = 78858
## Starting iteration 92 / 122
## neighbornet_objective for iteration 92 = 72448
## Starting iteration 93 / 122
## neighbornet_objective for iteration 93 = 81070
## Starting iteration 94 / 122
## neighbornet_objective for iteration 94 = 73675
## Starting iteration 95 / 122
## neighbornet_objective for iteration 95 = 73675
## Starting iteration 96 / 122
## neighbornet_objective for iteration 96 = 73661
## Starting iteration 97 / 122
## neighbornet_objective for iteration 97 = 71056
## Starting iteration 98 / 122
## neighbornet_objective for iteration 98 = 71003
## Starting iteration 99 / 122
## neighbornet_objective for iteration 99 = 89315
## Starting iteration 100 / 122
## neighbornet_objective for iteration 100 = 88889
## Starting iteration 101 / 122
## neighbornet_objective for iteration 101 = 115981
## Starting iteration 102 / 122
## neighbornet_objective for iteration 102 = 84167
## Starting iteration 103 / 122
## neighbornet_objective for iteration 103 = 83081
## Starting iteration 104 / 122
## neighbornet_objective for iteration 104 = 81046
## Starting iteration 105 / 122
## neighbornet_objective for iteration 105 = 78241
## Starting iteration 106 / 122
## neighbornet_objective for iteration 106 = 86713
## Starting iteration 107 / 122
## neighbornet_objective for iteration 107 = 73531
## Starting iteration 108 / 122
## neighbornet_objective for iteration 108 = 75541
## Starting iteration 109 / 122
## neighbornet_objective for iteration 109 = 85664
## Starting iteration 110 / 122
## neighbornet_objective for iteration 110 = 83844
## Starting iteration 111 / 122
## neighbornet_objective for iteration 111 = 84380
## Starting iteration 112 / 122
## neighbornet_objective for iteration 112 = 86888
## Starting iteration 113 / 122
## neighbornet_objective for iteration 113 = 75464
## Starting iteration 114 / 122
## neighbornet_objective for iteration 114 = 66759
## Starting iteration 115 / 122
## neighbornet_objective for iteration 115 = 75147
## Starting iteration 116 / 122
## neighbornet_objective for iteration 116 = 85767
## Starting iteration 117 / 122
## neighbornet_objective for iteration 117 = 69770
## Starting iteration 118 / 122
## neighbornet_objective for iteration 118 = 69836
## Starting iteration 119 / 122
## neighbornet_objective for iteration 119 = 69567
## Starting iteration 120 / 122
## neighbornet_objective for iteration 120 = 77881
## Starting iteration 121 / 122
## neighbornet_objective for iteration 121 = 68331
## Starting iteration 122 / 122
## neighbornet_objective for iteration 122 = 65695
## crossing edges objective = 62905
## Complete with sorting
## Plotting data
## Saving plot to=/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T//Rtmp1kOc9s/vignette_output/GoT_NN_lannister_origin.pdf
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

# df['Lannister_ending'] <- df["End.of.S7"] == 'Queen Cersei Lannister'
df <- df %>%
    mutate(Lannister_ending = case_when(
        End.of.S7 == "Queen Cersei Lannister" ~ 1,
        End.of.S7 == "Other, Westeros" ~ 2,
        TRUE ~ 0
    ))
p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "neighbornet", optimize_column_order = FALSE, color_boxes = FALSE, color_bands = TRUE, min_text = 0.01, verbose = TRUE, color_band_list = c("0" = "grey", "1" = "#D55E00", "2" = "#56B4E9"), color_band_column = "Lannister_ending", output_plot_path = file.path(output_dir, "GoT_NN_lannister_ending.pdf"), save_height = 24, save_width = 24, text_size = 35, axis_text_size = 25, axis_text_vjust = -5, text_width = 0.5)
## Loading in data
## Preprocessing data before sorting
## Alluvial statistics: n = number of elements; m = number of graphing columns; a = number of alluvia/edges; k_i = number of blocks in layer i (where i goes from 1:m); K_sum = number of blocks across all layers; K_prod = product of blocks across all layers
## n = 488
## m = 9
## a = 183
## k_1 = 13
## k_2 = 12
## k_3 = 17
## k_4 = 16
## k_5 = 14
## k_6 = 15
## k_7 = 16
## k_8 = 11
## k_9 = 8
## K_sum = 122
## K_prod = 12546293760
## Sorting data with sorting_algorithm=neighbornet
## Running neighbornet
## Running 'neighbornet' for stratum order
## Cycle: End.of.S1~~Balon Greyjoy, King of the Iron Islands, Origin~~House Greyjoy, End.of.S2~~Balon Greyjoy, King of the Iron Islands, End.of.S3~~Balon Greyjoy, King of the Iron Islands, End.of.S4~~Balon Greyjoy, King of the Iron Islands, End.of.S5~~Balon Greyjoy, King of the Iron Islands, End.of.S6~~Euron Greyjoy, King of the Iron Islands, Starting.Affiliation~~Deceased, End.of.S2~~Qarth, End.of.S1~~Qarth, Starting.Affiliation~~Qarth, End.of.S5~~Sons of the Harpy, End.of.S4~~Sons of the Harpy, Starting.Affiliation~~Essos Slavers, End.of.S2~~Essos Slavers, End.of.S1~~Essos Slavers, End.of.S3~~Essos Slavers, Starting.Affiliation~~Khal Drogo, End.of.S1~~Daenerys Targaryen, End.of.S2~~Daenerys Targaryen, End.of.S3~~Daenerys Targaryen, End.of.S4~~Daenerys Targaryen, End.of.S5~~Daenerys Targaryen, End.of.S7~~Daenerys Targaryen, End.of.S6~~Daenerys Targaryen, Origin~~Essos, End.of.S4~~Other, Essos, End.of.S3~~Other, Essos, End.of.S6~~Other, Essos, End.of.S7~~Other, Essos, End.of.S5~~Other, Essos, End.of.S1~~Other, Essos, End.of.S2~~Other, Essos, Starting.Affiliation~~Other, Essos, End.of.S4~~Dothraki, End.of.S1~~Dothraki, End.of.S2~~Dothraki, End.of.S3~~Dothraki, End.of.S5~~Dothraki, Starting.Affiliation~~Other Dothraki, End.of.S5~~Sand Snakes, End.of.S4~~Sand Snakes, Origin~~House Martell, Starting.Affiliation~~Viserys Targaryen, Origin~~House Targaryen, End.of.S1~~Night's Watch, Starting.Affiliation~~Night's Watch, End.of.S2~~Night's Watch, End.of.S3~~Night's Watch, End.of.S5~~Night's Watch, End.of.S6~~Night's Watch, End.of.S7~~Night's Watch, End.of.S4~~Night's Watch, End.of.S6~~Deceased, End.of.S1~~Deceased, End.of.S2~~Deceased, End.of.S3~~Deceased, End.of.S4~~Deceased, End.of.S5~~Deceased, End.of.S7~~Deceased, Origin~~House Stark, End.of.S5~~Roose Bolton, Lord Paramount of the North, End.of.S2~~Robb Stark, King in the North, End.of.S1~~Robb Stark, King in the North, Starting.Affiliation~~King Robert Baratheon, Origin~~House Tully, End.of.S3~~Other, Westeros, End.of.S5~~Other, Westeros, End.of.S7~~Other, Westeros, End.of.S6~~Other, Westeros, End.of.S4~~Other, Westeros, End.of.S2~~Other, Westeros, End.of.S1~~Other, Westeros, Starting.Affiliation~~Other, Westeros, Origin~~Westeros, End.of.S5~~High Sparrow, End.of.S3~~King Joffrey Baratheon, End.of.S4~~King Tommen Baratheon, End.of.S5~~King Tommen Baratheon, End.of.S6~~Queen Cersei Lannister, End.of.S7~~Queen Cersei Lannister, End.of.S2~~King Joffrey Baratheon, End.of.S1~~King Joffrey Baratheon, Origin~~House Lannister, Origin~~House Tyrell, End.of.S1~~King Renly Baratheon, Origin~~House Baratheon, End.of.S1~~King Stannis Baratheon, End.of.S3~~King Stannis Baratheon, End.of.S4~~King Stannis Baratheon, End.of.S2~~King Stannis Baratheon, End.of.S2~~Brotherhood Without Banners, End.of.S1~~Brotherhood Without Banners, End.of.S3~~Brotherhood Without Banners, End.of.S4~~Brotherhood Without Banners, End.of.S5~~Brotherhood Without Banners, End.of.S6~~Brotherhood Without Banners, Origin~~Wildlings, Starting.Affiliation~~Wildlings, End.of.S2~~Wildlings, End.of.S1~~Wildlings, End.of.S3~~Wildlings, End.of.S4~~Wildlings, End.of.S5~~Wildlings, End.of.S6~~Jon Snow, King in the North, End.of.S7~~Jon Snow, King in the North, Origin~~House Arryn, End.of.S4~~Petyr Baelish, Lord Protector of the Vale, End.of.S5~~Petyr Baelish, Lord Protector of the Vale, End.of.S3~~House Arryn (Neutral), End.of.S1~~House Arryn (Neutral), End.of.S2~~House Arryn (Neutral), End.of.S6~~Petyr Baelish, Lord Protector of the Vale, End.of.S7~~White Walkers, End.of.S5~~White Walkers, End.of.S6~~White Walkers, End.of.S4~~White Walkers, End.of.S3~~White Walkers, End.of.S1~~White Walkers, End.of.S2~~White Walkers, Starting.Affiliation~~White Walkers, Origin~~White Walkers
## Determining optimal cycle start
## Starting iteration 1 / 122
## neighbornet_objective for iteration 1 = 63295
## Starting iteration 2 / 122
## neighbornet_objective for iteration 2 = 68534
## Starting iteration 3 / 122
## neighbornet_objective for iteration 3 = 66798
## Starting iteration 4 / 122
## neighbornet_objective for iteration 4 = 67281
## Starting iteration 5 / 122
## neighbornet_objective for iteration 5 = 66553
## Starting iteration 6 / 122
## neighbornet_objective for iteration 6 = 66551
## Starting iteration 7 / 122
## neighbornet_objective for iteration 7 = 66090
## Starting iteration 8 / 122
## neighbornet_objective for iteration 8 = 62905
## Starting iteration 9 / 122
## neighbornet_objective for iteration 9 = 63194
## Starting iteration 10 / 122
## neighbornet_objective for iteration 10 = 64032
## Starting iteration 11 / 122
## neighbornet_objective for iteration 11 = 67407
## Starting iteration 12 / 122
## neighbornet_objective for iteration 12 = 66705
## Starting iteration 13 / 122
## neighbornet_objective for iteration 13 = 79919
## Starting iteration 14 / 122
## neighbornet_objective for iteration 14 = 79697
## Starting iteration 15 / 122
## neighbornet_objective for iteration 15 = 112217
## Starting iteration 16 / 122
## neighbornet_objective for iteration 16 = 146183
## Starting iteration 17 / 122
## neighbornet_objective for iteration 17 = 110984
## Starting iteration 18 / 122
## neighbornet_objective for iteration 18 = 101749
## Starting iteration 19 / 122
## neighbornet_objective for iteration 19 = 110091
## Starting iteration 20 / 122
## neighbornet_objective for iteration 20 = 115804
## Starting iteration 21 / 122
## neighbornet_objective for iteration 21 = 115704
## Starting iteration 22 / 122
## neighbornet_objective for iteration 22 = 113139
## Starting iteration 23 / 122
## neighbornet_objective for iteration 23 = 110998
## Starting iteration 24 / 122
## neighbornet_objective for iteration 24 = 110835
## Starting iteration 25 / 122
## neighbornet_objective for iteration 25 = 134620
## Starting iteration 26 / 122
## neighbornet_objective for iteration 26 = 99946
## Starting iteration 27 / 122
## neighbornet_objective for iteration 27 = 102125
## Starting iteration 28 / 122
## neighbornet_objective for iteration 28 = 128064
## Starting iteration 29 / 122
## neighbornet_objective for iteration 29 = 126205
## Starting iteration 30 / 122
## neighbornet_objective for iteration 30 = 151220
## Starting iteration 31 / 122
## neighbornet_objective for iteration 31 = 138340
## Starting iteration 32 / 122
## neighbornet_objective for iteration 32 = 110898
## Starting iteration 33 / 122
## neighbornet_objective for iteration 33 = 140859
## Starting iteration 34 / 122
## neighbornet_objective for iteration 34 = 112500
## Starting iteration 35 / 122
## neighbornet_objective for iteration 35 = 80640
## Starting iteration 36 / 122
## neighbornet_objective for iteration 36 = 99360
## Starting iteration 37 / 122
## neighbornet_objective for iteration 37 = 116358
## Starting iteration 38 / 122
## neighbornet_objective for iteration 38 = 116358
## Starting iteration 39 / 122
## neighbornet_objective for iteration 39 = 97638
## Starting iteration 40 / 122
## neighbornet_objective for iteration 40 = 84472
## Starting iteration 41 / 122
## neighbornet_objective for iteration 41 = 69510
## Starting iteration 42 / 122
## neighbornet_objective for iteration 42 = 70146
## Starting iteration 43 / 122
## neighbornet_objective for iteration 43 = 68182
## Starting iteration 44 / 122
## neighbornet_objective for iteration 44 = 69569
## Starting iteration 45 / 122
## neighbornet_objective for iteration 45 = 69871
## Starting iteration 46 / 122
## neighbornet_objective for iteration 46 = 70198
## Starting iteration 47 / 122
## neighbornet_objective for iteration 47 = 103703
## Starting iteration 48 / 122
## neighbornet_objective for iteration 48 = 93752
## Starting iteration 49 / 122
## neighbornet_objective for iteration 49 = 93940
## Starting iteration 50 / 122
## neighbornet_objective for iteration 50 = 93599
## Starting iteration 51 / 122
## neighbornet_objective for iteration 51 = 114908
## Starting iteration 52 / 122
## neighbornet_objective for iteration 52 = 114986
## Starting iteration 53 / 122
## neighbornet_objective for iteration 53 = 105626
## Starting iteration 54 / 122
## neighbornet_objective for iteration 54 = 83368
## Starting iteration 55 / 122
## neighbornet_objective for iteration 55 = 182857
## Starting iteration 56 / 122
## neighbornet_objective for iteration 56 = 195335
## Starting iteration 57 / 122
## neighbornet_objective for iteration 57 = 207356
## Starting iteration 58 / 122
## neighbornet_objective for iteration 58 = 217970
## Starting iteration 59 / 122
## neighbornet_objective for iteration 59 = 228331
## Starting iteration 60 / 122
## neighbornet_objective for iteration 60 = 147868
## Starting iteration 61 / 122
## neighbornet_objective for iteration 61 = 93244
## Starting iteration 62 / 122
## neighbornet_objective for iteration 62 = 113646
## Starting iteration 63 / 122
## neighbornet_objective for iteration 63 = 117666
## Starting iteration 64 / 122
## neighbornet_objective for iteration 64 = 156784
## Starting iteration 65 / 122
## neighbornet_objective for iteration 65 = 142976
## Starting iteration 66 / 122
## neighbornet_objective for iteration 66 = 130734
## Starting iteration 67 / 122
## neighbornet_objective for iteration 67 = 121388
## Starting iteration 68 / 122
## neighbornet_objective for iteration 68 = 165681
## Starting iteration 69 / 122
## neighbornet_objective for iteration 69 = 217180
## Starting iteration 70 / 122
## neighbornet_objective for iteration 70 = 238589
## Starting iteration 71 / 122
## neighbornet_objective for iteration 71 = 197797
## Starting iteration 72 / 122
## neighbornet_objective for iteration 72 = 141234
## Starting iteration 73 / 122
## neighbornet_objective for iteration 73 = 140881
## Starting iteration 74 / 122
## neighbornet_objective for iteration 74 = 139249
## Starting iteration 75 / 122
## neighbornet_objective for iteration 75 = 142303
## Starting iteration 76 / 122
## neighbornet_objective for iteration 76 = 118698
## Starting iteration 77 / 122
## neighbornet_objective for iteration 77 = 118629
## Starting iteration 78 / 122
## neighbornet_objective for iteration 78 = 169162
## Starting iteration 79 / 122
## neighbornet_objective for iteration 79 = 151874
## Starting iteration 80 / 122
## neighbornet_objective for iteration 80 = 144722
## Starting iteration 81 / 122
## neighbornet_objective for iteration 81 = 140100
## Starting iteration 82 / 122
## neighbornet_objective for iteration 82 = 126308
## Starting iteration 83 / 122
## neighbornet_objective for iteration 83 = 127234
## Starting iteration 84 / 122
## neighbornet_objective for iteration 84 = 94873
## Starting iteration 85 / 122
## neighbornet_objective for iteration 85 = 86574
## Starting iteration 86 / 122
## neighbornet_objective for iteration 86 = 86605
## Starting iteration 87 / 122
## neighbornet_objective for iteration 87 = 80011
## Starting iteration 88 / 122
## neighbornet_objective for iteration 88 = 73857
## Starting iteration 89 / 122
## neighbornet_objective for iteration 89 = 74761
## Starting iteration 90 / 122
## neighbornet_objective for iteration 90 = 80906
## Starting iteration 91 / 122
## neighbornet_objective for iteration 91 = 78858
## Starting iteration 92 / 122
## neighbornet_objective for iteration 92 = 72448
## Starting iteration 93 / 122
## neighbornet_objective for iteration 93 = 81070
## Starting iteration 94 / 122
## neighbornet_objective for iteration 94 = 73675
## Starting iteration 95 / 122
## neighbornet_objective for iteration 95 = 73675
## Starting iteration 96 / 122
## neighbornet_objective for iteration 96 = 73661
## Starting iteration 97 / 122
## neighbornet_objective for iteration 97 = 71056
## Starting iteration 98 / 122
## neighbornet_objective for iteration 98 = 71003
## Starting iteration 99 / 122
## neighbornet_objective for iteration 99 = 89315
## Starting iteration 100 / 122
## neighbornet_objective for iteration 100 = 88889
## Starting iteration 101 / 122
## neighbornet_objective for iteration 101 = 115981
## Starting iteration 102 / 122
## neighbornet_objective for iteration 102 = 84167
## Starting iteration 103 / 122
## neighbornet_objective for iteration 103 = 83081
## Starting iteration 104 / 122
## neighbornet_objective for iteration 104 = 81046
## Starting iteration 105 / 122
## neighbornet_objective for iteration 105 = 78241
## Starting iteration 106 / 122
## neighbornet_objective for iteration 106 = 86713
## Starting iteration 107 / 122
## neighbornet_objective for iteration 107 = 73531
## Starting iteration 108 / 122
## neighbornet_objective for iteration 108 = 75541
## Starting iteration 109 / 122
## neighbornet_objective for iteration 109 = 85664
## Starting iteration 110 / 122
## neighbornet_objective for iteration 110 = 83844
## Starting iteration 111 / 122
## neighbornet_objective for iteration 111 = 84380
## Starting iteration 112 / 122
## neighbornet_objective for iteration 112 = 86888
## Starting iteration 113 / 122
## neighbornet_objective for iteration 113 = 75464
## Starting iteration 114 / 122
## neighbornet_objective for iteration 114 = 66759
## Starting iteration 115 / 122
## neighbornet_objective for iteration 115 = 75147
## Starting iteration 116 / 122
## neighbornet_objective for iteration 116 = 85767
## Starting iteration 117 / 122
## neighbornet_objective for iteration 117 = 69770
## Starting iteration 118 / 122
## neighbornet_objective for iteration 118 = 69836
## Starting iteration 119 / 122
## neighbornet_objective for iteration 119 = 69567
## Starting iteration 120 / 122
## neighbornet_objective for iteration 120 = 77881
## Starting iteration 121 / 122
## neighbornet_objective for iteration 121 = 68331
## Starting iteration 122 / 122
## neighbornet_objective for iteration 122 = 65695
## crossing edges objective = 62905
## Complete with sorting
## Plotting data
## Saving plot to=/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T//Rtmp1kOc9s/vignette_output/GoT_NN_lannister_ending.pdf
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

Clustering

if (!requireNamespace("DuoClustering2018", quietly = TRUE)) {
    stop("Package 'DuoClustering2018' is needed for this vignette. Please install it with BiocManager::install('DuoClustering2018').")
}

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

# library(DuoClustering2018)
df_long <- DuoClustering2018::clustering_summary_filteredExpr10_Koh_v2()
## see ?DuoClustering2018 and browseVignettes('DuoClustering2018') for documentation
## loading from cache
# print(unique(df_long$method))
# graphing_columns <- c("PCAKmeans", "RtsneKmeans", "Seurat", "SC3")
graphing_columns <- c("RaceID2", "FlowSOM", "CIDR", "TSCAN", "PCAKmeans", "PCAHC", "SAFE", "pcaReduce", "RtsneKmeans", "monocle", "SC3svm", "Seurat", "SC3") # the order from the original study; ascend has no data

# shuffle graphing_columns
set.seed(43)
graphing_columns <- sample(graphing_columns)

head(df_long)
##                  dataset    method       cell run k resolution cluster
## 1 sce_filteredExpr10_Koh PCAKmeans SRR3952323   1 2         NA       1
## 2 sce_filteredExpr10_Koh PCAKmeans SRR3952325   1 2         NA       1
## 3 sce_filteredExpr10_Koh PCAKmeans SRR3952326   1 2         NA       1
## 4 sce_filteredExpr10_Koh PCAKmeans SRR3952327   1 2         NA       1
## 5 sce_filteredExpr10_Koh PCAKmeans SRR3952328   1 2         NA       1
## 6 sce_filteredExpr10_Koh PCAKmeans SRR3952329   1 2         NA       1
##   trueclass est_k elapsed
## 1    H7hESC    NA  14.318
## 2    H7hESC    NA  14.318
## 3    H7hESC    NA  14.318
## 4    H7hESC    NA  14.318
## 5    H7hESC    NA  14.318
## 6    H7hESC    NA  14.318

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

for (method_name in graphing_columns) {
    cat("Method:", method_name, "\n")

    df_sub <- df_long[df_long$method == method_name, ]

    cat("  Unique runs:       ", sort(unique(df_sub$run)), "\n")
    cat("  Unique k values:   ", sort(unique(df_sub$k)), "\n")
    cat("  Unique resolutions:", sort(unique(df_sub$resolution)), "\n\n")
}
## Method: Seurat 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    7 8 9 
##   Unique resolutions: 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 2.1 
## 
## Method: pcaReduce 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: TSCAN 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: PCAKmeans 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: FlowSOM 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: monocle 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: RtsneKmeans 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: SC3 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: SAFE 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: CIDR 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: PCAHC 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: RaceID2 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:  
## 
## Method: SC3svm 
##   Unique runs:        1 2 3 4 5 
##   Unique k values:    2 3 4 5 6 7 8 9 10 11 12 13 14 15 
##   Unique resolutions:

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

# keep only rows where run = 1, k = 9, and (for df_long$Seurat only) resolution = 2
df_long <- df_long %>%
    mutate(resolution = as.numeric(as.character(resolution))) %>%
    filter(
        run == 1,
        k == 9,
        method != "Seurat" | (method == "Seurat" & resolution == 2)
    )

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

# Add a unique row index per observation
df_long <- df_long %>%
    group_by(method) %>%
    mutate(obs_id = row_number()) %>%
    ungroup()

df <- df_long %>%
    select(obs_id, trueclass, method, cluster) %>%
    pivot_wider(
        id_cols = c(obs_id, trueclass),
        names_from = method,
        values_from = cluster
    ) %>%
    select(-obs_id) # optional: remove if obs_id is no longer needed

# df$FlowSOM <- NULL
df$ascend <- NULL

head(df)
## # A tibble: 6 × 14
##   trueclass PCAKmeans RtsneKmeans Seurat FlowSOM SC3   CIDR  PCAHC SC3svm
##   <chr>     <chr>     <chr>       <chr>  <chr>   <chr> <chr> <chr> <chr> 
## 1 H7hESC    4         9           5      4       4     1     1     3     
## 2 H7hESC    4         9           5      4       4     1     1     3     
## 3 H7hESC    4         9           5      4       4     1     1     3     
## 4 H7hESC    4         9           5      4       4     1     1     3     
## 5 H7hESC    4         9           5      4       4     1     1     3     
## 6 H7hESC    4         9           5      4       4     1     1     3     
## # ℹ 5 more variables: pcaReduce <chr>, TSCAN <chr>, SAFE <chr>, monocle <chr>,
## #   RaceID2 <chr>

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

Subsample for debugging

sample_size <- NULL # NULL for full sample
if (!is.null(sample_size)) {
    set.seed(42)
    df <- df %>% slice_sample(n = sample_size)
} else {
    sample_size <- "full"
}

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

set.seed(42)
p <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "random", coloring_algorithm = "left", resolution = 12, verbose = TRUE, output_plot_path = file.path(output_dir, sprintf("clustering_%s_random.pdf", sample_size)), min_text = 0.01, save_height = 24, save_width = 24, rasterise_alluvia = FALSE, dpi = 50, color_boxes = FALSE, color_bands = TRUE, color_band_list = c("H7hESC" = "#D55E00", "H7_derived_APS" = "#56B4E9", "H7_derived_MPS" = "#009E73", "H7_derived_DLL1pPXM" = "#F0E442", "H7_derived_ESMT" = "#0072B2", "H7_derived_Sclrtm" = "#E69F00", "H7_derived_D5CntrlDrmmtm" = "#CC79A7", "H7_derived_D2LtM" = "#666666", "H7_dreived_D2.25_Smtmrs" = "#AD7700"), color_band_column = "trueclass", text_size = 35, axis_text_size = 20, axis_text_vjust = -5)
## Loading in data
## Preprocessing data before sorting
## Alluvial statistics: n = number of elements; m = number of graphing columns; a = number of alluvia/edges; k_i = number of blocks in layer i (where i goes from 1:m); K_sum = number of blocks across all layers; K_prod = product of blocks across all layers
## n = 531
## m = 13
## a = 137
## k_1 = 9
## k_2 = 9
## k_3 = 9
## k_4 = 9
## k_5 = 9
## k_6 = 9
## k_7 = 9
## k_8 = 9
## k_9 = 7
## k_10 = 9
## k_11 = 9
## k_12 = 9
## k_13 = 9
## K_sum = 115
## K_prod = 1977006755367
## Sorting data with sorting_algorithm=random
## Determining crossing edges objective (to disable, use verbose==FALSE)
## crossing edges objective = 625967
## Complete with sorting
## Plotting data
## Saving plot to=/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T//Rtmp1kOc9s/vignette_output/clustering_full_random.pdf
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

p2 <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "neighbornet", coloring_algorithm = "left", resolution = 12, verbose = TRUE, optimize_column_order = FALSE, output_plot_path = file.path(output_dir, sprintf("clustering_%s_NN.pdf", sample_size)), min_text = 0.01, save_height = 24, save_width = 24, rasterise_alluvia = FALSE, dpi = 50, color_boxes = FALSE, color_bands = TRUE, color_band_list = c("H7hESC" = "#D55E00", "H7_derived_APS" = "#56B4E9", "H7_derived_MPS" = "#009E73", "H7_derived_DLL1pPXM" = "#F0E442", "H7_derived_ESMT" = "#0072B2", "H7_derived_Sclrtm" = "#E69F00", "H7_derived_D5CntrlDrmmtm" = "#CC79A7", "H7_derived_D2LtM" = "#666666", "H7_dreived_D2.25_Smtmrs" = "#AD7700"), color_band_column = "trueclass", text_size = 35, axis_text_size = 20, axis_text_vjust = -5)
## Loading in data
## Preprocessing data before sorting
## Alluvial statistics: n = number of elements; m = number of graphing columns; a = number of alluvia/edges; k_i = number of blocks in layer i (where i goes from 1:m); K_sum = number of blocks across all layers; K_prod = product of blocks across all layers
## n = 531
## m = 13
## a = 137
## k_1 = 9
## k_2 = 9
## k_3 = 9
## k_4 = 9
## k_5 = 9
## k_6 = 9
## k_7 = 9
## k_8 = 9
## k_9 = 7
## k_10 = 9
## k_11 = 9
## k_12 = 9
## k_13 = 9
## K_sum = 115
## K_prod = 1977006755367
## Sorting data with sorting_algorithm=neighbornet
## Running neighbornet
## Running 'neighbornet' for stratum order
## Cycle: CIDR~~1, monocle~~3, pcaReduce~~5, SC3~~4, Seurat~~5, TSCAN~~2, SAFE~~5, FlowSOM~~4, SC3svm~~5, SAFE~~1, RtsneKmeans~~7, PCAHC~~3, TSCAN~~1, Seurat~~3, pcaReduce~~7, CIDR~~3, PCAKmeans~~7, SC3~~5, monocle~~2, CIDR~~2, FlowSOM~~3, Seurat~~8, monocle~~8, PCAKmeans~~3, TSCAN~~4, pcaReduce~~4, SC3~~8, SC3svm~~4, monocle~~9, monocle~~4, Seurat~~6, PCAKmeans~~1, SC3svm~~6, CIDR~~9, pcaReduce~~1, FlowSOM~~2, PCAHC~~8, SC3~~9, TSCAN~~5, RtsneKmeans~~3, SAFE~~7, RaceID2~~8, PCAHC~~2, FlowSOM~~5, Seurat~~2, PCAHC~~6, RtsneKmeans~~6, TSCAN~~9, FlowSOM~~1, pcaReduce~~2, CIDR~~6, SC3~~7, SC3svm~~9, RaceID2~~9, PCAKmeans~~9, CIDR~~8, SAFE~~2, pcaReduce~~8, monocle~~6, PCAHC~~7, RaceID2~~2, FlowSOM~~7, CIDR~~7, PCAKmeans~~6, Seurat~~4, RtsneKmeans~~1, SC3~~6, SC3svm~~7, FlowSOM~~6, RaceID2~~3, TSCAN~~7, RaceID2~~5, RaceID2~~7, CIDR~~5, TSCAN~~8, FlowSOM~~9, Seurat~~7, SC3svm~~8, SC3~~2, RtsneKmeans~~5, pcaReduce~~9, PCAKmeans~~8, monocle~~1, PCAHC~~5, SAFE~~6, RaceID2~~6, PCAHC~~4, monocle~~5, PCAKmeans~~5, pcaReduce~~3, RtsneKmeans~~2, SC3~~1, SC3svm~~1, Seurat~~1, TSCAN~~3, RaceID2~~4, TSCAN~~6, RtsneKmeans~~4, Seurat~~0, SC3svm~~2, SC3~~3, pcaReduce~~6, PCAKmeans~~2, monocle~~7, PCAHC~~9, SAFE~~4, CIDR~~4, FlowSOM~~8, RtsneKmeans~~8, RaceID2~~1, SAFE~~3, SC3svm~~3, RtsneKmeans~~9, PCAKmeans~~4, PCAHC~~1
## Determining optimal cycle start
## Starting iteration 1 / 115
## neighbornet_objective for iteration 1 = 266745
## Starting iteration 2 / 115
## neighbornet_objective for iteration 2 = 242075
## Starting iteration 3 / 115
## neighbornet_objective for iteration 3 = 234499
## Starting iteration 4 / 115
## neighbornet_objective for iteration 4 = 280131
## Starting iteration 5 / 115
## neighbornet_objective for iteration 5 = 252263
## Starting iteration 6 / 115
## neighbornet_objective for iteration 6 = 226083
## Starting iteration 7 / 115
## neighbornet_objective for iteration 7 = 217050
## Starting iteration 8 / 115
## neighbornet_objective for iteration 8 = 195925
## Starting iteration 9 / 115
## neighbornet_objective for iteration 9 = 211371
## Starting iteration 10 / 115
## neighbornet_objective for iteration 10 = 202535
## Starting iteration 11 / 115
## neighbornet_objective for iteration 11 = 279791
## Starting iteration 12 / 115
## neighbornet_objective for iteration 12 = 356664
## Starting iteration 13 / 115
## neighbornet_objective for iteration 13 = 375476
## Starting iteration 14 / 115
## neighbornet_objective for iteration 14 = 397544
## Starting iteration 15 / 115
## neighbornet_objective for iteration 15 = 427264
## Starting iteration 16 / 115
## neighbornet_objective for iteration 16 = 376293
## Starting iteration 17 / 115
## neighbornet_objective for iteration 17 = 313519
## Starting iteration 18 / 115
## neighbornet_objective for iteration 18 = 263827
## Starting iteration 19 / 115
## neighbornet_objective for iteration 19 = 186571
## Starting iteration 20 / 115
## neighbornet_objective for iteration 20 = 127180
## Starting iteration 21 / 115
## neighbornet_objective for iteration 21 = 114042
## Starting iteration 22 / 115
## neighbornet_objective for iteration 22 = 135799
## Starting iteration 23 / 115
## neighbornet_objective for iteration 23 = 146759
## Starting iteration 24 / 115
## neighbornet_objective for iteration 24 = 125747
## Starting iteration 25 / 115
## neighbornet_objective for iteration 25 = 122360
## Starting iteration 26 / 115
## neighbornet_objective for iteration 26 = 119258
## Starting iteration 27 / 115
## neighbornet_objective for iteration 27 = 109616
## Starting iteration 28 / 115
## neighbornet_objective for iteration 28 = 109694
## Starting iteration 29 / 115
## neighbornet_objective for iteration 29 = 110120
## Starting iteration 30 / 115
## neighbornet_objective for iteration 30 = 108977
## Starting iteration 31 / 115
## neighbornet_objective for iteration 31 = 203818
## Starting iteration 32 / 115
## neighbornet_objective for iteration 32 = 227260
## Starting iteration 33 / 115
## neighbornet_objective for iteration 33 = 274913
## Starting iteration 34 / 115
## neighbornet_objective for iteration 34 = 299303
## Starting iteration 35 / 115
## neighbornet_objective for iteration 35 = 350799
## Starting iteration 36 / 115
## neighbornet_objective for iteration 36 = 349711
## Starting iteration 37 / 115
## neighbornet_objective for iteration 37 = 306590
## Starting iteration 38 / 115
## neighbornet_objective for iteration 38 = 302044
## Starting iteration 39 / 115
## neighbornet_objective for iteration 39 = 349240
## Starting iteration 40 / 115
## neighbornet_objective for iteration 40 = 300742
## Starting iteration 41 / 115
## neighbornet_objective for iteration 41 = 248734
## Starting iteration 42 / 115
## neighbornet_objective for iteration 42 = 205462
## Starting iteration 43 / 115
## neighbornet_objective for iteration 43 = 187319
## Starting iteration 44 / 115
## neighbornet_objective for iteration 44 = 190849
## Starting iteration 45 / 115
## neighbornet_objective for iteration 45 = 193892
## Starting iteration 46 / 115
## neighbornet_objective for iteration 46 = 210108
## Starting iteration 47 / 115
## neighbornet_objective for iteration 47 = 244884
## Starting iteration 48 / 115
## neighbornet_objective for iteration 48 = 249967
## Starting iteration 49 / 115
## neighbornet_objective for iteration 49 = 295672
## Starting iteration 50 / 115
## neighbornet_objective for iteration 50 = 296150
## Starting iteration 51 / 115
## neighbornet_objective for iteration 51 = 255553
## Starting iteration 52 / 115
## neighbornet_objective for iteration 52 = 254888
## Starting iteration 53 / 115
## neighbornet_objective for iteration 53 = 245794
## Starting iteration 54 / 115
## neighbornet_objective for iteration 54 = 252696
## Starting iteration 55 / 115
## neighbornet_objective for iteration 55 = 213700
## Starting iteration 56 / 115
## neighbornet_objective for iteration 56 = 171262
## Starting iteration 57 / 115
## neighbornet_objective for iteration 57 = 180906
## Starting iteration 58 / 115
## neighbornet_objective for iteration 58 = 176510
## Starting iteration 59 / 115
## neighbornet_objective for iteration 59 = 230510
## Starting iteration 60 / 115
## neighbornet_objective for iteration 60 = 287955
## Starting iteration 61 / 115
## neighbornet_objective for iteration 61 = 319415
## Starting iteration 62 / 115
## neighbornet_objective for iteration 62 = 325665
## Starting iteration 63 / 115
## neighbornet_objective for iteration 63 = 326482
## Starting iteration 64 / 115
## neighbornet_objective for iteration 64 = 284047
## Starting iteration 65 / 115
## neighbornet_objective for iteration 65 = 324551
## Starting iteration 66 / 115
## neighbornet_objective for iteration 66 = 295439
## Starting iteration 67 / 115
## neighbornet_objective for iteration 67 = 295545
## Starting iteration 68 / 115
## neighbornet_objective for iteration 68 = 235407
## Starting iteration 69 / 115
## neighbornet_objective for iteration 69 = 242831
## Starting iteration 70 / 115
## neighbornet_objective for iteration 70 = 195061
## Starting iteration 71 / 115
## neighbornet_objective for iteration 71 = 193749
## Starting iteration 72 / 115
## neighbornet_objective for iteration 72 = 128577
## Starting iteration 73 / 115
## neighbornet_objective for iteration 73 = 136551
## Starting iteration 74 / 115
## neighbornet_objective for iteration 74 = 118438
## Starting iteration 75 / 115
## neighbornet_objective for iteration 75 = 165621
## Starting iteration 76 / 115
## neighbornet_objective for iteration 76 = 205921
## Starting iteration 77 / 115
## neighbornet_objective for iteration 77 = 246841
## Starting iteration 78 / 115
## neighbornet_objective for iteration 78 = 267825
## Starting iteration 79 / 115
## neighbornet_objective for iteration 79 = 265255
## Starting iteration 80 / 115
## neighbornet_objective for iteration 80 = 306793
## Starting iteration 81 / 115
## neighbornet_objective for iteration 81 = 306793
## Starting iteration 82 / 115
## neighbornet_objective for iteration 82 = 267413
## Starting iteration 83 / 115
## neighbornet_objective for iteration 83 = 227483
## Starting iteration 84 / 115
## neighbornet_objective for iteration 84 = 185927
## Starting iteration 85 / 115
## neighbornet_objective for iteration 85 = 158649
## Starting iteration 86 / 115
## neighbornet_objective for iteration 86 = 114156
## Starting iteration 87 / 115
## neighbornet_objective for iteration 87 = 145897
## Starting iteration 88 / 115
## neighbornet_objective for iteration 88 = 164859
## Starting iteration 89 / 115
## neighbornet_objective for iteration 89 = 232495
## Starting iteration 90 / 115
## neighbornet_objective for iteration 90 = 284965
## Starting iteration 91 / 115
## neighbornet_objective for iteration 91 = 347085
## Starting iteration 92 / 115
## neighbornet_objective for iteration 92 = 347085
## Starting iteration 93 / 115
## neighbornet_objective for iteration 93 = 323523
## Starting iteration 94 / 115
## neighbornet_objective for iteration 94 = 307473
## Starting iteration 95 / 115
## neighbornet_objective for iteration 95 = 273655
## Starting iteration 96 / 115
## neighbornet_objective for iteration 96 = 222693
## Starting iteration 97 / 115
## neighbornet_objective for iteration 97 = 260801
## Starting iteration 98 / 115
## neighbornet_objective for iteration 98 = 317407
## Starting iteration 99 / 115
## neighbornet_objective for iteration 99 = 358106
## Starting iteration 100 / 115
## neighbornet_objective for iteration 100 = 396016
## Starting iteration 101 / 115
## neighbornet_objective for iteration 101 = 379988
## Starting iteration 102 / 115
## neighbornet_objective for iteration 102 = 414076
## Starting iteration 103 / 115
## neighbornet_objective for iteration 103 = 342072
## Starting iteration 104 / 115
## neighbornet_objective for iteration 104 = 342966
## Starting iteration 105 / 115
## neighbornet_objective for iteration 105 = 365174
## Starting iteration 106 / 115
## neighbornet_objective for iteration 106 = 363918
## Starting iteration 107 / 115
## neighbornet_objective for iteration 107 = 349962
## Starting iteration 108 / 115
## neighbornet_objective for iteration 108 = 253767
## Starting iteration 109 / 115
## neighbornet_objective for iteration 109 = 135471
## Starting iteration 110 / 115
## neighbornet_objective for iteration 110 = 101256
## Starting iteration 111 / 115
## neighbornet_objective for iteration 111 = 119325
## Starting iteration 112 / 115
## neighbornet_objective for iteration 112 = 146191
## Starting iteration 113 / 115
## neighbornet_objective for iteration 113 = 144595
## Starting iteration 114 / 115
## neighbornet_objective for iteration 114 = 196587
## Starting iteration 115 / 115
## neighbornet_objective for iteration 115 = 245923
## crossing edges objective = 101256
## Complete with sorting
## Plotting data
## Saving plot to=/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T//Rtmp1kOc9s/vignette_output/clustering_full_NN.pdf
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.
p2
## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

## Warning in to_lodes_form(data = data, axes = axis_ind, discern =
## params$discern): Some strata appear at multiple axes.

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

Optional (only if I’m doing a subset of objectives)

# log_msgs <- character()
#
# withCallingHandlers({
#   p2 <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "neighbornet", verbose=TRUE, optimize_column_order = FALSE, output_plot_path=file.path(output_dir, sprintf("clustering_%s_NN.pdf", sample_size)), min_text = 0.01, save_height = 24, save_width = 24, rasterise_alluvia = FALSE, dpi = 50, color_boxes = FALSE, color_bands = TRUE, color_band_list = c("H7hESC" = "#D55E00", "H7_derived_APS" = "#56B4E9", "H7_derived_MPS" = "#009E73", "H7_derived_DLL1pPXM" = "#F0E442", "H7_derived_ESMT" = "#0072B2", "H7_derived_Sclrtm" = "#E69F00", "H7_derived_D5CntrlDrmmtm" = "#CC79A7", "H7_derived_D2LtM" = "#666666", "H7_dreived_D2.25_Smtmrs" = "#AD7700"), color_band_column = 'trueclass')
# }, message = function(m) {
#   log_msgs <<- c(log_msgs, conditionMessage(m))
#   # no muffling → still prints to console
# })
# p2

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

# objectives <- stringr::str_match(log_msgs, "neighbornet_objective for iteration \\d+ = (\\d+)")[, 2]
# objectives <- as.numeric(na.omit(objectives))
#
# df_obj <- data.frame(
#   iteration = seq_along(objectives),
#   objective = objectives
# )
#
# ggplot(df_obj, aes(x = iteration, y = objective)) +
#   geom_line(color = "blue") +
#   scale_x_continuous(
#     breaks = seq(0, length(objectives), by = 5),     # major ticks
#     minor_breaks = seq(0, length(objectives), by = 1)  # minor ticks
#   ) +
#   labs(title = "NeighborNet Objective Over Iterations",
#        x = "Iteration", y = "Objective") +
#   theme_minimal()

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

cycle_start_positions <- NULL # c(110) - 110 for NN, 34 for TSP  # c(12:25, 130:150)  # c(40:60, 140:160)  # choose based on finding some local optima above
column_sorting_metric <- "edge_crossing" # edge_crossing or ARI
optimize_column_order_per_cycle <- TRUE

set.seed(42)
p3 <- plot_alluvial(df, graphing_columns = graphing_columns, sorting_algorithm = "neighbornet", coloring_algorithm = "left", resolution = 12, verbose = TRUE, optimize_column_order = TRUE, optimize_column_order_per_cycle = optimize_column_order_per_cycle, output_plot_path = file.path(output_dir, sprintf("clustering_%s_NN_optimized_columns.pdf", sample_size)), min_text = 0.01, save_height = 24, save_width = 24, rasterise_alluvia = FALSE, dpi = 50, color_boxes = FALSE, color_bands = TRUE, color_band_list = c("H7hESC" = "#D55E00", "H7_derived_APS" = "#56B4E9", "H7_derived_MPS" = "#009E73", "H7_derived_DLL1pPXM" = "#F0E442", "H7_derived_ESMT" = "#0072B2", "H7_derived_Sclrtm" = "#E69F00", "H7_derived_D5CntrlDrmmtm" = "#CC79A7", "H7_derived_D2LtM" = "#666666", "H7_dreived_D2.25_Smtmrs" = "#AD7700"), color_band_column = "trueclass", cycle_start_positions = cycle_start_positions, column_sorting_metric = column_sorting_metric, text_size = 35, axis_text_size = 20, axis_text_vjust = -5)
p3

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

Make legend

# Ensure color_band_list is a named vector
color_band_list <- c(
    "Lannister" = "#D55E00",
    "Westeros" = "#56B4E9"
)

# Make a dummy data frame just for the legend
legend_df <- data.frame(Gene = names(color_band_list))

# Plot with invisible points to show only the legend
legend_plot <- ggplot(legend_df, aes(x = 1, y = Gene, color = Gene)) +
    geom_line(linewidth = 5) +
    scale_color_manual(values = color_band_list, name = "Affiliation") +
    theme_void() +
    theme(legend.position = "right")

ggsave(file.path(output_dir, "GoT_legend.pdf"), plot = legend_plot)
## Saving 8 x 5 in image
## `geom_line()`: Each group consists of only one observation.
## ℹ Do you need to adjust the group aesthetic?

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

# Ensure color_band_list is a named vector
color_band_list <- c(
    "H7hESC" = "#D55E00",
    "H7_derived_APS" = "#56B4E9",
    "H7_derived_MPS" = "#009E73",
    "H7_derived_DLL1pPXM" = "#F0E442",
    "H7_derived_ESMT" = "#0072B2",
    "H7_derived_Sclrtm" = "#E69F00",
    "H7_derived_D5CntrlDrmmtm" = "#CC79A7",
    "H7_derived_D2LtM" = "#666666",
    "H7_dreived_D2.25_Smtmrs" = "#AD7700"
)

# Make a dummy data frame just for the legend
legend_df <- data.frame(trueclass = names(color_band_list))

# Plot with invisible points to show only the legend
legend_plot <- ggplot(legend_df, aes(x = 1, y = trueclass, color = trueclass)) +
    geom_line(linewidth = 5) +
    scale_color_manual(values = color_band_list, name = "True Class") +
    theme_void() +
    theme(legend.position = "right")

ggsave(file.path(output_dir, sprintf("clustering_%s_legend.pdf", sample_size)), plot = legend_plot)
## Saving 8 x 5 in image
## `geom_line()`: Each group consists of only one observation.
## ℹ Do you need to adjust the group aesthetic?

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R

sessioninfo::session_info()
## ─ Session info ───────────────────────────────────────────────────────────────
##  setting  value
##  version  R version 4.3.1 (2023-06-16)
##  os       macOS Ventura 13.5.2
##  system   aarch64, darwin20
##  ui       X11
##  language (EN)
##  collate  en_US.UTF-8
##  ctype    en_US.UTF-8
##  tz       America/Los_Angeles
##  date     2025-08-21
##  pandoc   3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)
## 
## ─ Packages ───────────────────────────────────────────────────────────────────
##  ! package                * version   date (UTC) lib source
##    AnnotationDbi            1.63.2    2023-07-03 [2] Bioconductor
##    AnnotationHub            3.10.0    2023-10-26 [2] Bioconductor
##    Biobase                  2.61.0    2023-06-02 [2] Bioconductor
##    BiocFileCache            2.9.1     2023-07-14 [2] Bioconductor
##    BiocGenerics             0.47.0    2023-06-02 [2] Bioconductor
##    BiocManager              1.30.22   2023-08-08 [2] CRAN (R 4.3.0)
##    BiocStyle              * 2.30.0    2023-10-26 [2] Bioconductor
##    BiocVersion              3.18.0    2023-05-11 [2] Bioconductor
##    Biostrings               2.69.2    2023-07-05 [2] Bioconductor
##    bit                      4.0.5     2022-11-15 [2] CRAN (R 4.3.0)
##    bit64                    4.0.5     2020-08-30 [2] CRAN (R 4.3.0)
##    bitops                   1.0-7     2021-04-24 [2] CRAN (R 4.3.0)
##    blob                     1.2.4     2023-03-17 [2] CRAN (R 4.3.0)
##    bookdown                 0.43      2025-04-15 [2] CRAN (R 4.3.3)
##    brio                     1.1.3     2021-11-30 [2] CRAN (R 4.3.0)
##    bslib                    0.5.1     2023-08-11 [2] CRAN (R 4.3.0)
##    cachem                   1.0.8     2023-05-01 [2] CRAN (R 4.3.0)
##    callr                    3.7.3     2022-11-02 [2] CRAN (R 4.3.0)
##    cli                      3.6.1     2023-03-23 [2] CRAN (R 4.3.0)
##    codetools                0.2-19    2023-02-01 [2] CRAN (R 4.3.1)
##    colorspace               2.1-0     2023-01-23 [2] CRAN (R 4.3.0)
##    crayon                   1.5.2     2022-09-29 [2] CRAN (R 4.3.0)
##    curl                     5.0.2     2023-08-14 [2] CRAN (R 4.3.0)
##    data.table               1.14.8    2023-02-17 [2] CRAN (R 4.3.0)
##    DBI                      1.1.3     2022-06-18 [2] CRAN (R 4.3.0)
##    dbplyr                   2.3.3     2023-07-07 [2] CRAN (R 4.3.0)
##    desc                     1.4.2     2022-09-08 [2] CRAN (R 4.3.0)
##    devtools                 2.4.5     2022-10-11 [2] CRAN (R 4.3.0)
##    digest                   0.6.33    2023-07-07 [2] CRAN (R 4.3.0)
##    dplyr                  * 1.1.3     2023-09-03 [2] CRAN (R 4.3.0)
##    DuoClustering2018      * 1.20.0    2023-10-26 [2] Bioconductor
##    ellipsis                 0.3.2     2021-04-29 [2] CRAN (R 4.3.0)
##    evaluate                 0.21      2023-05-05 [2] CRAN (R 4.3.0)
##    ExperimentHub            2.10.0    2023-10-26 [2] Bioconductor
##    fansi                    1.0.4     2023-01-22 [2] CRAN (R 4.3.0)
##    farver                   2.1.1     2022-07-06 [2] CRAN (R 4.3.0)
##    fastmap                  1.1.1     2023-02-24 [2] CRAN (R 4.3.0)
##    filelock                 1.0.2     2018-10-05 [2] CRAN (R 4.3.0)
##    foreach                  1.5.2     2022-02-02 [2] CRAN (R 4.3.3)
##    fs                       1.6.3     2023-07-20 [2] CRAN (R 4.3.0)
##    generics                 0.1.3     2022-07-05 [2] CRAN (R 4.3.0)
##    GenomeInfoDb             1.37.4    2023-09-07 [2] Bioconductor
##    GenomeInfoDbData         1.2.10    2023-09-14 [2] Bioconductor
##    ggalluvial             * 0.12.5    2023-02-22 [2] CRAN (R 4.3.0)
##    ggfittext                0.10.2    2024-02-01 [2] CRAN (R 4.3.1)
##    ggforce                * 0.4.2     2024-02-19 [2] CRAN (R 4.3.1)
##    ggplot2                * 3.4.3     2023-08-14 [2] CRAN (R 4.3.0)
##    ggthemes                 5.1.0     2024-02-10 [2] CRAN (R 4.3.1)
##    glue                     1.6.2     2022-02-24 [2] CRAN (R 4.3.0)
##    gridExtra                2.3       2017-09-09 [2] CRAN (R 4.3.0)
##    gtable                   0.3.4     2023-08-21 [2] CRAN (R 4.3.0)
##    here                     1.0.1     2020-12-13 [2] CRAN (R 4.3.0)
##    htmltools                0.5.6     2023-08-10 [2] CRAN (R 4.3.0)
##    htmlwidgets              1.6.2     2023-03-17 [2] CRAN (R 4.3.0)
##    httpuv                   1.6.11    2023-05-11 [2] CRAN (R 4.3.0)
##    httr                     1.4.7     2023-08-15 [2] CRAN (R 4.3.0)
##    igraph                 * 1.5.1     2023-08-10 [2] CRAN (R 4.3.0)
##    interactiveDisplayBase   1.40.0    2023-10-26 [2] Bioconductor
##    IRanges                  2.35.2    2023-06-23 [2] Bioconductor
##    iterators                1.0.14    2022-02-05 [2] CRAN (R 4.3.3)
##    jquerylib                0.1.4     2021-04-26 [2] CRAN (R 4.3.0)
##    jsonlite                 1.8.7     2023-06-29 [2] CRAN (R 4.3.0)
##    KEGGREST                 1.41.0    2023-07-07 [2] Bioconductor
##    knitr                    1.44      2023-09-11 [2] CRAN (R 4.3.1)
##    labeling                 0.4.3     2023-08-29 [2] CRAN (R 4.3.0)
##    later                    1.3.1     2023-05-02 [2] CRAN (R 4.3.0)
##    lattice                  0.21-8    2023-04-05 [2] CRAN (R 4.3.1)
##    lifecycle                1.0.3     2022-10-07 [2] CRAN (R 4.3.0)
##    magick                   2.8.6     2025-03-23 [2] CRAN (R 4.3.3)
##    magrittr                 2.0.3     2022-03-30 [2] CRAN (R 4.3.0)
##    MASS                     7.3-60    2023-05-04 [2] CRAN (R 4.3.1)
##    Matrix                   1.6-5     2024-01-11 [2] CRAN (R 4.3.1)
##    mclust                   6.1.1     2024-04-29 [2] CRAN (R 4.3.3)
##    memoise                  2.0.1     2021-11-26 [2] CRAN (R 4.3.0)
##    mime                     0.12      2021-09-28 [2] CRAN (R 4.3.0)
##    miniUI                   0.1.1.1   2018-05-18 [2] CRAN (R 4.3.0)
##    munsell                  0.5.0     2018-06-12 [2] CRAN (R 4.3.0)
##    pillar                   1.9.0     2023-03-22 [2] CRAN (R 4.3.0)
##    pkgbuild                 1.4.2     2023-06-26 [2] CRAN (R 4.3.0)
##    pkgconfig                2.0.3     2019-09-22 [2] CRAN (R 4.3.0)
##    pkgload                  1.3.2.1   2023-07-08 [2] CRAN (R 4.3.0)
##    plyr                     1.8.8     2022-11-11 [2] CRAN (R 4.3.0)
##    png                      0.1-8     2022-11-29 [2] CRAN (R 4.3.0)
##    polyclip                 1.10-4    2022-10-20 [2] CRAN (R 4.3.0)
##    prettyunits              1.1.1     2020-01-24 [2] CRAN (R 4.3.0)
##    processx                 3.8.2     2023-06-30 [2] CRAN (R 4.3.0)
##    profvis                  0.3.8     2023-05-02 [2] CRAN (R 4.3.0)
##    promises                 1.2.1     2023-08-10 [2] CRAN (R 4.3.0)
##    ps                       1.7.5     2023-04-18 [2] CRAN (R 4.3.0)
##    purrr                    1.0.2     2023-08-10 [2] CRAN (R 4.3.0)
##    R6                       2.5.1     2021-08-19 [2] CRAN (R 4.3.0)
##    ragg                     1.2.5     2023-01-12 [2] CRAN (R 4.3.0)
##    rappdirs                 0.3.3     2021-01-31 [2] CRAN (R 4.3.0)
##    Rcpp                     1.0.11    2023-07-06 [2] CRAN (R 4.3.0)
##    RCurl                    1.98-1.12 2023-03-27 [2] CRAN (R 4.3.0)
##    remotes                  2.4.2.1   2023-07-18 [2] CRAN (R 4.3.0)
##    reshape2                 1.4.4     2020-04-09 [2] CRAN (R 4.3.0)
##    reticulate             * 1.32.0    2023-09-11 [2] CRAN (R 4.3.1)
##    rlang                    1.1.1     2023-04-28 [2] CRAN (R 4.3.0)
##    rmarkdown                2.24      2023-08-14 [2] CRAN (R 4.3.0)
##    rprojroot                2.0.3     2022-04-02 [2] CRAN (R 4.3.0)
##    RSQLite                  2.3.1     2023-04-03 [2] CRAN (R 4.3.0)
##    rstudioapi               0.15.0    2023-07-07 [2] CRAN (R 4.3.0)
##    S4Vectors                0.39.1    2023-06-02 [2] Bioconductor
##    sass                     0.4.7     2023-07-15 [2] CRAN (R 4.3.0)
##    scales                   1.2.1     2022-08-20 [2] CRAN (R 4.3.0)
##    sessioninfo              1.2.2     2021-12-06 [2] CRAN (R 4.3.0)
##    shiny                    1.7.5     2023-08-12 [2] CRAN (R 4.3.0)
##    stringi                  1.7.12    2023-01-11 [2] CRAN (R 4.3.0)
##    stringr                  1.5.0     2022-12-02 [2] CRAN (R 4.3.0)
##    systemfonts              1.0.4     2022-02-11 [2] CRAN (R 4.3.0)
##    testthat               * 3.1.10    2023-07-06 [2] CRAN (R 4.3.0)
##    textshaping              0.3.6     2021-10-13 [2] CRAN (R 4.3.0)
##    tibble                 * 3.2.1     2023-03-20 [2] CRAN (R 4.3.0)
##    tidyr                  * 1.3.0     2023-01-24 [2] CRAN (R 4.3.0)
##    tidyselect               1.2.0     2022-10-10 [2] CRAN (R 4.3.0)
##    TSP                      1.2-5     2025-05-27 [2] CRAN (R 4.3.3)
##    tweenr                   2.0.3     2024-02-26 [2] CRAN (R 4.3.1)
##    urlchecker               1.0.1     2021-11-30 [2] CRAN (R 4.3.0)
##    usethis                  3.1.0     2024-11-26 [2] CRAN (R 4.3.3)
##    utf8                     1.2.3     2023-01-31 [2] CRAN (R 4.3.0)
##    vctrs                    0.6.3     2023-06-14 [2] CRAN (R 4.3.0)
##    viridis                  0.6.4     2023-07-22 [2] CRAN (R 4.3.0)
##    viridisLite              0.4.2     2023-05-02 [2] CRAN (R 4.3.0)
##    withr                    2.5.0     2022-03-03 [2] CRAN (R 4.3.0)
##  P wompwomp               * 0.99.0    2025-08-22 [?] Bioconductor
##    xfun                     0.52      2025-04-02 [2] CRAN (R 4.3.3)
##    xtable                   1.8-4     2019-04-21 [2] CRAN (R 4.3.0)
##    XVector                  0.41.1    2023-06-02 [2] Bioconductor
##    yaml                     2.3.7     2023-01-23 [2] CRAN (R 4.3.0)
##    zlibbioc                 1.47.0    2023-05-20 [2] Bioconductor
## 
##  [1] /private/var/folders/wr/wdr46lxn7fbc_kty6kwbfhxc0000gn/T/Rtmpg9hbdf/temp_libpathc9607864a1d
##  [2] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
## 
##  P ── Loaded and on-disk path mismatch.
## 
## ─ Python configuration ───────────────────────────────────────────────────────
##  python:         /Users/joeyrich/miniconda3/envs/wompwomp_env/bin/python
##  libpython:      /Users/joeyrich/miniconda3/envs/wompwomp_env/lib/libpython3.10.dylib
##  pythonhome:     /Users/joeyrich/miniconda3/envs/wompwomp_env:/Users/joeyrich/miniconda3/envs/wompwomp_env
##  version:        3.10.16 (main, Dec 11 2024, 10:22:29) [Clang 14.0.6 ]
##  numpy:          /Users/joeyrich/miniconda3/envs/wompwomp_env/lib/python3.10/site-packages/numpy
##  numpy_version:  1.23.5
##  splitspy:       /Users/joeyrich/miniconda3/envs/wompwomp_env/lib/python3.10/site-packages/splitspy
##  
##  NOTE: Python version was forced by use_python() function
## 
## ──────────────────────────────────────────────────────────────────────────────

/Users/joeyrich/Desktop/local/wompwomp/vignettes/examples-with-large-data.R